package com.wyt.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wyt.dao.OrderDetMapper;
import com.wyt.dao.OrderMapper;
import com.wyt.until.PageEntity;
import com.wyt.until.TableLayui;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author AAA
 * @date 2021/10/29 18:42("/tee
 */
@Controller
@RequestMapping("/orderDet")
public class OrderDetController {
    @Autowired
    private OrderDetMapper orderDetMapper;

    //查询、检索
    @ResponseBody
    @RequestMapping("/selectTeacher")
    public TableLayui selectBook(PageEntity pageEntity,@RequestParam Map map) {
        PageHelper.startPage(pageEntity.getPage(), pageEntity.getLimit());

        List<Map> list= orderDetMapper.selectDetOrder(map);
        PageInfo pageInfo=new PageInfo(list);

        return new TableLayui(pageInfo.getTotal(),pageInfo.getList());
    }

    //根据id判断增加还是修改
    @ResponseBody
    @RequestMapping("/insertTeacher")
    public TableLayui insertBook1(@RequestParam Map map){
        System.out.println(map);
        if (map.get("id")!=null&&map.get("id")!=""){
            orderDetMapper.updateDetOrder(map);
            return new TableLayui(1,"失败",map);
        }
        orderDetMapper.insertDetOrder(map);
        return new TableLayui(1,"失败",map);
    }


//删除
    @ResponseBody
    @RequestMapping("/deleteTeacher")
    public TableLayui deleteBokk(@RequestParam Map map){
        orderDetMapper.deleteDetOrder(map);
        return new TableLayui(1,"失败");
    }



}
